package com.grts.mall.controller;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.grts.mall.common.OrderResultVo;
import com.grts.mall.pojo.Order;
import com.grts.mall.pojo.vo.OrderSearchConditionVO;
import com.grts.mall.service.OrderService;

@Controller
public class OrderController {

	@Autowired
	private OrderService orderService;

	@RequestMapping("/order/manage")
	public String manage() {
		return "order/manage";
	}

	@RequestMapping("/order/list")
	@ResponseBody
	public OrderResultVo list(OrderSearchConditionVO vo) {
		HashMap<Long, String> states = new HashMap<Long,String>();
//		订单的状态：1（待付款）2（待发货）3（待收货）4（待评价）5（已完成）6（已取消）
		states.put(new Long(1),"待付款");
		states.put(new Long(2), "待发货");
		states.put(new Long(3), "待收货");
		states.put(new Long(4), "待评价");
		states.put(new Long(5), "已完成");
		states.put(new Long(6), "已取消");
		long count = this.orderService.countByExaple(vo);
		List<Order> list = this.orderService.findAll(vo);
		return new OrderResultVo(0, "ok", list, count);
	}

}
